<?

/**
 *  draws a standard text input field.  this field can
 *  be turned into a "live" field by including the
 *  url and update attributes.
 *
 */

function smarty_function_field( $params, $smarty ) {

	// standard atttibutes
	$name = Smutty_Smarty::getFieldName( $params['name'] );
	$maxlength = $params['maxlength'] ? $params['maxlength'] : 50;
	$liveField = '';

	// add a label?
	if ( $label = $params['label'] ) {
		$smarty->depend( 'function', 'label' );
		smarty_function_label(array(
			'for' => $params['name'],
			text => $label
		), $smarty );
	}

	// is it a "live" field?
	if ( $params['url'] && $params['update'] )
		$liveField = 'onkeyup="smutty_ajaxLiveFieldChange(' .
			'\'' . Smutty_Utils::getUrl(Smutty_Utils::strToHash($params['url'])) . '\',' .
			'\'' . $params['update'] . '\',' .
			'this,' .
			'\'' . $params['feedback'] . '\'' .
		');"';

	// draw the field
	echo '<input type="text" ' .
		'name="' . $name . '" ' .
		'maxlength="' . $maxlength . '" ' .
		$liveField . ' />';


}

?>